// load file
use data/main_file.dta, clear

// create variable for neighboring visits
cap drop visited_mun visited_neigh visited_only_neigh 
bys mun_code year: egen visited_mun = sum(visited)
gen visited_neigh = (visited_mun > visited)
gen visited_only_neigh = (visited_neigh & visited == 0)

// erase previous versions of table A2
cap erase tabs/T0A2.tex
cap erase tabs/T0A2.txt

// create table A2
reghdfe Chavismo i.HCR##i.visited i.HCR##i.focal							///
		i.HCR##c.log_den i.HCR##c.log_pov									///
		i.HCR##c.baseline_ch i.HCR##c.sh_urbano [aw = log_pop],				///
		vce(cluster loc) absorb(loc i.edo##i.year)
outreg2 using tabs/T0A2.tex, append 										///
		keep(1.HCR#1.visited 1.HCR#1.focal 1.HCR#1.visited#1.focal			///
		1.HCR#1.visited_neigh 1.HCR#1.visited_neigh#1.focal)				///
		addtext(Covariates, Yes, State-Election FE, Yes, Parish FE, Yes) 	
		
reghdfe Chavismo i.HCR##i.visited_neigh i.HCR##i.focal						///
		i.HCR##c.log_den i.HCR##c.log_pov									///
		i.HCR##c.baseline_ch i.HCR##c.sh_urbano [aw = log_pop],				///
		vce(cluster loc) absorb(loc i.edo##i.year)	
outreg2 using tabs/T0A2.tex, append 										///
		keep(1.HCR#1.visited 1.HCR#1.focal 1.HCR#1.visited#1.focal			///
		1.HCR#1.visited_neigh 1.HCR#1.visited_neigh#1.focal)				///
		addtext(Covariates, Yes, State-Election FE, Yes, Parish FE, Yes) 	
					
reghdfe Chavismo i.HCR##i.visited i.HCR##i.visited_neigh i.HCR##i.focal		///
		i.HCR##c.log_den i.HCR##c.log_pov									///
		i.HCR##c.baseline_ch i.HCR##c.sh_urbano [aw = log_pop],				///
		vce(cluster loc) absorb(loc i.edo##i.year)				
outreg2 using tabs/T0A2.tex, append 										///
		keep(1.HCR#1.visited 1.HCR#1.focal 1.HCR#1.visited#1.focal			///
		1.HCR#1.visited_neigh 1.HCR#1.visited_neigh#1.focal)				///
		addtext(Covariates, Yes, State-Election FE, Yes, Parish FE, Yes) 	
